﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FTI
{
    public static partial class Extensions
    {
        public static ISource SourceByName(this IEnumerable<ISource> Sources, string name)
        {
            return Sources
                .Single(X => X.Name.Eq(name));
        }

        public static IEnumerable<IDestination> DestinationByName(this IEnumerable<IDestination> Destinations, string name)
        {
            return Destinations
                .Where(X => X.Name.Eq(name));
        }

        public static IDestination DestinationByName(this IEnumerable<IDestination> Destinations, string name, ISource source)
        {
            return Destinations
                .DestinationByName(name)
                .Single(X => 
                    X.IsSourceSupported(source));
        }
    }
}
